<template>
	<view>
		<u-popup v-model="couponShow" mode="bottom" width="750rpx" height="1080rpx" :border-radius="16"
			:mask-close-able="false">
			<view class="coupon_pup">
				<view class="header_title">
					<view class="left">
						选择优惠券
					</view>
					<u-icon name="close" size="34" color="#666666" @click="close"></u-icon>
				</view>
				<view class="tabs">
					<view v-for="(item,index) in tabsList" :key="index" class="tabItem" @click="changeTabs(index)">
						<view class="size"
							:style="{color:TabsCurrent == index ?'#73F0EA':'#999999',fontWeight:TabsCurrent == index ?'800':'400'}">
							{{item.name}}
						</view>
						<view class="sliding-block-box">
							<view class="sliding-block-child" v-if="TabsCurrent == index">
							
							</view>
						</view>
						
					</view>
				</view>
				<scroll-view scroll-y="true" class="scroll_box">
					<view class="comlum_box" v-if="popupList.length">
						<view v-for="(item,index) in popupList" :key="index" class="item" :style="{opacity:TabsCurrent == 1?'0.6':'1'}">
							<view class="header" @click="changeCouponActive(index)">
								<!-- 满减 -->
								<view class="left">
									<view class="minus">
										<view class="unit">
											￥
										</view>
										<view class="number">
											{{item.face}}
										</view>
									</view>
									<view class="full">
										{{item.threshold}}
									</view>
								</view>
								<!-- 虚线 -->
								<view class="height-dotted-line">
								</view>
								<!-- 名称 -->
								<view class="right">
									<view class="name-of-shop">
										<view class="title">
											{{item.name}}
										</view>
										<view class="time">
											使用期限：{{item.in_date}}
										</view>
									</view>
									<image
										:src="couponActive !== index?$IMG_URL('/static/member/agreement1.png'):$IMG_URL('/static/member/agreement2.png')"
										mode="" class="agreement" v-if="!TabsCurrent"></image>
								</view>
							</view>
							<!-- 虚线 -->
							<view class="width-dotted-line">
							</view>
							<view class="Folding-panel">
								<view class="row-box" @click="toggle(index)">
									<view class="official">
										{{item.top_ast}}
									</view>
									<u-icon :name="item.open?'arrow-up':'arrow-down'" size="14"
										color="#dbdbdb"></u-icon>
								</view>
								<view class="remark" v-if="item.open">
									<view v-for="(item,index) in item.ast_list" :key="index">
										{{item}}
									</view>
								</view>
							</view>
						</view>
					</view>
					<empty v-else :content="'优惠券'"></empty>
				</scroll-view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	export default {
		components:{
			empty
		},
		props: {
			couponShow: {
				type: Boolean,
				default: false,
				required: true
			},
			tabsList: {
				type: Array,
				default: [],
				required: true
			},
			TabsCurrent: {
				type: Number,
				default: 0,
				required: true
			},
			popupList: {
				type: Array,
				default: [],
				required: true
			},
			couponActive: {
				type: Number,
				default: 0,
				required: true
			}
		},
		data() {
			return {}
		},
		methods: {
			close() {
				this.$emit('close', false)
			},
			changeCouponActive(index) {
				this.$emit('changeActive', index)
			},
			toggle(index) {
				this.$emit('toggle', index)
				// this.$set(this.popupList[index], 'isOpen', !this.popupList[index].isOpen);
			},
			changeTabs(index) {
				this.$emit('changeTabs', index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.coupon_pup {
		width: 750rpx;
		height: 1080rpx;
		border-radius: 16rpx 16rpx 0 0;

		.header_title {
			padding: 30rpx 30rpx 0 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;

			.left {
				font-size: 36rpx;
				font-family: PingFang SC, PingFang SC-Bold;
				font-weight: 700;
				text-align: left;
				color: #333333;
				flex: 1;
			}
		}

		.tabs {
			margin-top: 30rpx;
			height: 60rpx;
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-around;

			.tabItem {
				display: flex;
				flex-direction: column;
				align-items: center;
				height: 60rpx;
				.size{
					font-size: 28rpx;
					letter-spacing: 0.62rpx;
					font-family: PingFang SC, PingFang SC-Heavy;
				}
				.sliding-block-box{
					height: 20rpx;
					padding-top: 12rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
				}
				.sliding-block-child {
					width: 44rpx;
					height: 8rpx;
					background: #73F0EA;
					border: 2rpx solid rgba(0, 0, 0, 0.00);
					border-radius: 2rpx;
				}
			}	
		}

		.scroll_box {
			height: 850rpx;
			width: 100%;
			margin-top: 28rpx;

			.comlum_box {
				width: 100%;
				padding: 0 24rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				.item {
					width: 100%;
					// padding: 28rpx 32rpx;
					background: #f6f6f6;
					border-radius: 16rpx;
					display: flex;
					flex-direction: column;
					margin-bottom: 20rpx;
					z-index: 22;

					.header {
						width: 100%;
						height: 158rpx;
						display: flex;
						flex-direction: row;
						align-items: center;

						.left {
							width: 185rpx;
							display: flex;
							flex-direction: column;
							align-items: center;
							padding-left: 32rpx;

							.minus {
								display: flex;
								flex-direction: row;
								align-items: baseline;
								margin-bottom: 2rpx;

								.unit {
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Bold;
									font-weight: 700;
									text-align: left;
									color: #f37364;
								}

								.number {
									font-size: 45rpx;
									font-family: DIN, DIN-Bold;
									font-weight: 700;
									text-align: left;
									color: #f37364;
								}
							}

							.full {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Medium;
								font-weight: 500;
								text-align: center;
								color: #666666;
							}
						}

						.height-dotted-line {
							width: 0rpx;
							height: 118rpx;
							opacity: 0.1;
							border: 1rpx dashed #333333;
							margin:0 33rpx;
						}

						.right {
							flex: 1;
							padding-right: 32rpx;
							display: flex;
							flex-direction: row;
							align-items: center;

							.name-of-shop {
								display: flex;
								flex-direction: column;
								flex: 1;

								.title {
									font-size: 32rpx;
									font-family: PingFang SC, PingFang SC-Bold;
									font-weight: 700;
									text-align: left;
									color: #333333;
									margin-bottom: 8rpx;
								}

								.time {
									font-size: 20rpx;
									font-family: PingFang SC, PingFang SC-Regular;
									font-weight: 400;
									text-align: left;
									color: #666666;
								}
							}

							.agreement {
								width: 36rpx;
								height: 36rpx;
							}
						}
					}

					// 虚线
					.width-dotted-line {
						opacity: 0.1;
						border: 1rpx dashed #333333;
					}

					// 折叠面板
					.Folding-panel {
						display: flex;
						flex-direction: column;
						width: 100%;
						padding: 18rpx 32rpx 16rpx;

						.row-box {
							width: 100%;
							display: flex;
							flex-direction: row;
							align-items: center;
							padding-bottom: 12rpx;

							.official {
								font-size: 24rpx;
								font-family: PingFang SC, PingFang SC-Regular;
								font-weight: 400;
								text-align: left;
								color: #666666;
								flex: 1;
							}
						}

						.remark {
							display: flex;
							flex-direction: column;
							width: 578rpx;
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Regular;
							font-weight: 400;
							text-align: left;
							color: #666666;
							line-height: 28rpx;
						}
					}
				}
			}

		}

	}
</style>